package 力扣日常刷题.木22二月.第12天218;

/**
 * @author 帅小伙
 * @date 2022/2/18
 * @description
 */
public class Demo88JZ构建乘积数组 {

    public int[] constructArray(int[] array) {
        int len = array.length;
        if(len == 0) return new int[0];
        int[] b = new int[len];
        b[0] = 1;
        int t = 1;
        for (int i = 1; i < len; i++) b[i] = b[i - 1] * array[i - 1];

        // t 维护右
        for (int i = len - 2; i >= 0; i--) {
            t *= array[i+1];
            b[i] *= t;
        }
        return b;
    }
}
